#pragma once

#include <esp_types.h>
#include <driver/gpio.h>

#define X_AXIS 0
#define Y_AXIS 1
#define Z_AXIS 2

#define TYPE_STEP 0
#define TYPE_DIR 1
#define TYPE_ENA 2
#define TYPE_ENB 3

typedef struct
{
    union
    {
        struct {
            uint8_t axis :2;
            uint8_t type :2;
            uint8_t unused :4;
        };
        uint8_t val;
    };
} PkgType_t;

typedef struct
{
    uint16_t  len;
    PkgType_t pkg_type;
    uint64_t  tick;
    uint8_t   data[0];
} PkgAxisData_t;

void pkg_init(uint16_t size);
void pkg_release();
void pkg_send(PkgType_t type,uint64_t tick,int8_t* data,uint16_t len);


typedef struct AxisMonitor
{
    gpio_num_t step_pin;
    gpio_num_t dir_pin;
    gpio_num_t enc_a;
    gpio_num_t enc_b;

} AxisMonitor_t;

void axis_monitor(uint8_t axis,gpio_num_t step_pin,gpio_num_t dir_pin,gpio_num_t enc_a,gpio_num_t enc_b);
